#ifndef ANX_RTT_CONFIG_H
#define ANX_RTT_CONFIG_H


#include "SEGGER_RTT_Conf.h"
#include "SEGGER_RTT.h"

#include "string.h"
#include <stdlib.h>
#include <stdarg.h>

int Anx_RTT_printf(unsigned terminal, const char* sFormat, ...);

#define LEVEL_LOG 3
#define LEVEL_WAR 2
#define LEVEL_ERR 1
#define LEVEL_NOT 0

#define DEBUG_ENABLE 1
#define DEBUG_CIR_ENABLE 1
#define DEBUG_LEVEL LEVEL_LOG


#ifdef DEBUG_ENABLE

#define  Debug_init()                                                             \
 do{                                                                              \
    SEGGER_RTT_ConfigUpBuffer(0,"RTTUP",NULL,0,SEGGER_RTT_MODE_NO_BLOCK_SKIP);    \
	  SEGGER_RTT_ConfigDownBuffer(0,"RTTDOWN",NULL,0,SEGGER_RTT_MODE_NO_BLOCK_SKIP);\
	  SEGGER_RTT_SetTerminal(0);                                                    \
  } while (0)

//常规日志，用于流程的日志
#if (DEBUG_LEVEL >= LEVEL_ERR)
#define Debug_err(log,format,...) Anx_RTT_printf(0,RTT_CTRL_TEXT_RED "[%s] " format "\n",log,##__VA_ARGS__)
#else 
#define Debug_err(log,format,...) 
#endif

#if (DEBUG_LEVEL >= LEVEL_WAR)
#define Debug_war(log,format,...) Anx_RTT_printf(0,RTT_CTRL_TEXT_YELLOW "[%s] " format "\n",log,##__VA_ARGS__)
#else 
#define Debug_war(log,format,...)
#endif

#if (DEBUG_LEVEL >= LEVEL_LOG)
#define Debug_log(log,format,...) Anx_RTT_printf(0,RTT_CTRL_TEXT_BLACK"[%s] " format "\n",log,##__VA_ARGS__)
// #define Debug_log(log,format,...) Anx_RTT_printf(0,RTT_CTRL_TEXT_WHITE "[%s] " format "\n",log,##__VA_ARGS__)
#else 
#define Debug_log(log,format,...)
#endif


#ifdef DEBUG_CIR_ENABLE
//循环日志，用于循环的日志
#define Debug_cir(log,format,...) Anx_RTT_printf(1,RTT_CTRL_TEXT_BLACK "[%s] " format "\n",log,##__VA_ARGS__);
#else
#define Debug_cir(log,format,...) 
#endif


#else
#define Debug(format,...)
#define Debug_err(log,format,...) 
#define Debug_war(log,format,...)
#define Debug_log(log,format,...)

#define Debug_cir(log,format,...) 
#endif

#endif
/*************************** End of file ****************************/
